<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面</title>

    <link rel="stylesheet" href="css/commom.css">
    <link rel="stylesheet" href="css/login.css">

</head>
<body>

    <!-- nav 是导航单词的缩写 -->
    <div class="nav">
        <!-- 博客系统的logo -->
        <!-- <img src="image/QQ图片20221112113838.jpg" alt=""> -->
        <!-- <span class="title">我的博客系统</span> -->
        <!-- spacer不显示内容, 只是占位 将a标签撑到右侧去 -->
        <div class="spacer"></div>
        <!-- <a href="blog_list.html" target="_blank">主页</a> -->
        <!-- <a href="blog_edit.html" target="_blank">写博客</a> -->
        <!-- <a href="#">注销</a> -->
    </div>

    <!-- 用这个元素作为页面的版心 -->
    <div class="login-container">
        <!-- 登录对话框 -->
        <div class="dialog">
            <h3>博客系统</h3>
            <!-- 用户名 -->
            <div class="row">
                <span>用户名</span>
                <input type="text" id="username" placeholder="手机号/邮箱/用户名"> 
            </div>
            <!-- 密码 -->
            <div class="row">
                <span>密码</span>
                <input type="password" id="password" placeholder="密码">
            </div>
            <div class="row">
                <!-- <button id="login-button">登录</button> -->
                <a href="login.html" id="myLogin">登录</a>
            </div>
        </div>
    </div>

    <!-- 自己想的javascript代码 -->
    <script>
        let inputs = document.querySelectorAll('input');
        // 默认用户名: 18722864552
        let myUsername = '111';
        // 默认密码: lijiaqiang1024
        let myPassword = '222';
        // let myLogin = document.querySelector('#myLogin');
       
        myLogin.onclick = function() {
            let username = inputs[0].value;
            let password = inputs[1].value;
            // console.log(username);
            // console.log(username == myUsername);
            if(username != myUsername || password != myPassword) {
                alert('用户名或密码错误!');
            } else {
                // 账户密码输入正确就重设a标签的网址.
                document.getElementById('myLogin').href = "blog_list.html";
            }
        }
    </script>

</body>
</html>